Method of refreshing data stored on a disk

ABSTRACT

According to one embodiment, a disk comprises an area which comprises a plurality of data tracks and is partitioned into a first segment and a plurality of second segments. A controller detects that a segment to be refreshed next is one of the plurality of second segments. The controller saves data stored in the one of the plurality of second segments into the first segment when a segment to be refreshed next is the one of the plurality of second segments.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based upon and claims the benefit of priority fromJapanese Patent Application No. 2009-173501, filed Jul. 24, 2009, theentire contents of which are incorporated herein by reference.

BACKGROUND

1. Field

One embodiment of the invention relates to a method of refreshing datastored on, for example, a disk.

2. Description of the Related Art

In recent years, with the increasing storage capacity of magnetic diskdrives, the recording density and track density have been gettinghigher. As the track density gets higher, the distance (i.e., trackpitch) between adjacent tracks (or data tracks) on the disk getsshorter. Each track has the same width as that of the head (or a writingelement included in the head). However, the width of the distribution ofthe recording magnetic field produced by the head in a write operationdoes not necessarily coincide with the width of the head, with theresult that the magnetic field is also applied to the surrounding area.This state is known as write fringing.

If the track pitch is made narrower, there is a possibility that thedata (or recorded data) written on adjacent tracks will deteriorate inwriting data onto the tracks. The deterioration of data is attributableto write fringing and errors in positioning the head on the track. Ifthe recorded data is deteriorated repeatedly, it becomes very difficultto read the data. That is, even if an attempt is made to restore therecorded data by making best use of an error-correcting code (ECC), itis difficult to restore the data.

With this backdrop, in the field of recent magnetic disk drives, datarefreshing (or rewriting) is indispensable for restoring the recordeddata before the data becomes unreadable due to data deterioration. As amethod of returning the recorded data to the normal state, an operationcalled data refreshing exists, in which the deteriorated recorded datais read from, and then rewritten to a track.

For example, Jpn. Pat. Appln. KOKAI Publication No. 2004-273060 hasdisclosed a technique for refreshing the data written on a trackadjacent to a track whose number of data writes has reached a specificvalue (hereinafter, referred to as the related art). According to therelated art, first, it is determined that the data on a track adjacentto a track whose number of data writes has reached a specific value hasdeteriorated. Next, the data on such an adjacent track is read as datato be refreshed and is stored temporarily into a RAM. Then, the data onthe adjacent track temporarily stored in the RAM is written again ontothe adjacent track. That is, the data on a track to be refreshed isrewritten with the data read from the track. By such a data rewritingoperation, or a data refreshing operation, the data is restored from thedeterioration.

In the related art, however, if the power supply of the magnetic diskdrive is shut down during a data refreshing operation, the data on atrack to be refreshed can be lost. More specifically, if the powersupply of the magnetic disk drive is shut down during the operation ofwriting the data read from a track to be refreshed onto the track again(hereinafter, referred to as a rewrite operation), the data can be lost.The reason why this is so will be explained below.

First, suppose the power supply is shut down during a rewrite operation.In this case, the data on a track to be refreshed is destroyed. At thistime, the data on the track to be refreshed temporarily stored in theRAM disappears. Accordingly, even if the power supply is restored, theunfinished rewrite operation cannot be performed again, with the resultthat the data on the track to be refreshed is lost.

To prevent such a problem, use of a specific track on the disk in placeof the RAM is considered. That is, use of a specific track on the diskas a save area (or a backup track) for temporarily saving (i.e., backingup) the data on the track to be refreshed is considered.

When a specific track on the disk is used as a save area, a saveoperation and a rewrite operation are carried out as follows. In a saveoperation, the data read from a track to be refreshed is written onto(or saved to) a specific track. In a rewrite operation, the data readfrom a specific track is rewritten onto the track to be refreshed, withthe result that the data recorded on the track to be refreshed isrefreshed.

In a save operation, a first seek operation is performed to move thehead from the track to be refreshed to a specific track. In a rewriteoperation, a second seek operation is performed to move the head fromthe specific track to the track to be refreshed.

As described above, when a specific track is used as a save area, twoseek operations are required to refresh the data on a single track.Generally, recent disks have about 160,000 tracks per recording surface.In a magnetic disk drive with such a disk, the head has to move over along distance corresponding to an average of 160,000 tracks to refreshthe data on a single track.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

A general architecture that implements various features of the inventionwill now be described with reference to the drawings. The drawings andtheir associated descriptions are provided to illustrate the embodimentsof the invention and not to limit the scope of the invention.

FIG. 1 is a block diagram showing an exemplary configuration of amagnetic disk drive (HDD) according to an embodiment of the invention;

FIG. 2 is a conceptual diagram showing an exemplary format including thetrack arrangement of a disk applied to the embodiment;

FIG. 3 is a schematic diagram to explain an exemplary data refreshingprocess applied to the embodiment;

FIG. 4 shows an example of a data structure of a write count tableapplied to the embodiment;

FIG. 5 is an exemplary flowchart to explain an overall operation of theHDD of FIG. 1;

FIG. 6 is an exemplary flowchart to explain a detailed procedure for aninitialization and restoration process included in the flowchart of FIG.5;

FIG. 7 is an exemplary flowchart to explain a detailed procedure for acommand execution process included in the flowchart of FIG. 5; and

FIGS. 8 and 9 respectively show first and second parts of an exemplaryflowchart to explain a detailed procedure for a data refreshing processincluded in the flowchart of FIG. 5.

DETAILED DESCRIPTION

Various embodiments according to the invention will be describedhereinafter with reference to the accompanying drawings. In general,according to one embodiment of the invention, there is provided a methodof refreshing data stored on a disk in a magnetic disk drive. The methodcomprises: detecting that a segment to be refreshed next is one of aplurality of second segments, the disk comprising an area whichcomprises a plurality of data tracks and is partitioned into a firstsegment and the plurality of second segments; and saving second datastored in the one of the plurality of second segments into the firstsegment when a segment to be refreshed next is the one of the pluralityof second segments.

FIG. 1 is a block diagram showing the configuration of a magnetic diskdrive (HDD) according to an embodiment of the invention. The HDD 100shown in FIG. 1 is a storage device for writing data onto the recordingsurface of a disk (or a magnetic disk) 101 or read the data from therecording surface according to a request from a host system 200. Thehost system 200 is a device, such as a personal computer, which uses theHDD 100 as a storage device.

The disk 101, which is secured to a spindle motor (SPM) 103, rotates ata constant speed as a result of the SPM 103 being driven. For example,one side of the disk 101 is a recording surface onto which data isrecorded magnetically. A head (or magnetic head) 102 is arranged so asto face the recording surface of the disk 101. The head 102 is securedto one end of an actuator 105. The other end of the actuator 105 issecured to a voice coil motor (VCM) 104. With the VCM 104 being driven,the head 102 moves over a part of the circular arc trajectory around thepivot of the VCM 104, the part overlapping with the surface of the disk101.

The configuration of FIG. 1 is based on the assumption that the HDD 100includes a single disk 101. However, the configuration may be such thata plurality of disks 101 are secured to the SPM 103 in such a mannerthat the disks 101 are spaced at equal intervals. In this case, aplurality of actuators 105 are secured to the VCM 104 in such a mannerthat the actuators 105 overlap with the disks 101 so as to correspond tothe intervals of the disks 101. A head 102 is secured to one end of eachof the plurality of actuators 105. Accordingly, when the SPM 103 isdriven, all the disks 101 rotate simultaneously. When the VCM 104 isdriven, all the heads 102 move simultaneously. In the configuration ofFIG. 1, one side of the disk 101 is a recording surface. Both sides ofthe disk 101 may be recording surfaces and heads 102 may be arranged soas to correspond to the respective recording surfaces.

FIG. 2 is a conceptual diagram showing a format including the trackarrangement of the disk 101. In FIG. 2, on the recording surface of thedisk 101, a plurality of tracks (or data tracks) 201 are arrangedconcentrically. The data received by the HDD 100 from the host system200 is recorded to at least one of the plurality of tracks 201 accordingto an address specified by the host system 200.

On the plurality of tracks 201 of the disk 101, servo areas 202 and dataareas 203 are arranged alternately at equal intervals. In each of theservo areas 202, a servo signal used to position the head 102 isrecorded. Each of the data areas 203 is used to record data transferredfrom the host system 200.

To return to FIG. 1, a CPU 115 functions as the main controller of theHDD 100. The CPU 115 performs control via a motor driver 106 to startand stop the SPM 103 and maintain the rotational speed. The CPU 115 alsoperforms drive control of the VCM 104 via the motor driver 106, therebyperforming control of moving the head 102 to the target track and ofsettling the head in the target range of the track. Control of movingthe head 102 to the target track is known as seek control. Control ofsettling the head 102 in the target range of the target track is knownas head positioning control. The CPU 115 further performs control ofrefreshing the data written in the track 201 on the disk 101 (datarefreshing process).

The positioning of the head 102 is performed in a state where the SPM103 is rotating steadily after start-up. As described above, the servoareas 202 (see FIG. 2) are arranged equiangularly. Accordingly, theservo signals recorded in the servo areas 202 appear in equal intervalsof time in an analog signal read by the head 102 from the disk 101 andamplified by a head IC 107. A read/write IC 108 (or a servo module 121included in the read/write IC 108) and a gate array 109 process theanalog signal making use of this state, thereby generating a signal forpositioning the head 102. On the basis of the positioning signal, theCPU 115 controls the motor driver 106 to cause the motor driver 106 tosupply a current for positioning the head 102 (or a VCM current) to theVCM 104 in real time. The CPU 115 not only controls the SPM 103 and VCM104 via the motor driver 106 but also controls other components of theHDD 100 and executes a command process and the like. The CPU 115 isconnected to a CPU bus 112.

Connected to the CPU bus 112 are the read/write IC 108, the gate array109, a disk controller (HDC) 110, a RAM 113, and a flash ROM 114. Theflash ROM 114 is a rewritable nonvolatile memory. The flash ROM 114 isrewritten under the control of the CPU 115. In the flash ROM 114, aprogram to be executed by the CPU 115 has been stored. Theaforementioned control performed by the CPU 115 is realized as a resultof the CPU 115 executing the program.

The RAM 113 is used to store, for example, various variables used by theCPU 115. A part of the storage area of the RAM 113 is used as a workarea of the CPU 115. Another part of the storage area of the RAM 113 isused to store a write count table 400 (see FIG. 4) which holds a writecount (or the number of writes) for each track group. The track groupand write count table 400 will be described later.

The read/write IC 108 includes a servo module 121 and a read/writemodule 122. The servo module 121 carries out a signal process necessaryto position the head 102, including the extraction of a servo signal.The read/write module 122 executes a signal process for reading andwriting data. The gate array 109 generates various control signals,including a signal for the servo module 121 to extract a servo signal.

The HDC 110 is connected not only to the CPU bus 112 but also to theread/write IC 108, the gate array 109, and a buffer RAM 111. The HDC 110includes a host module 123, a read/write module 124, and a buffer module125. The host module 123 has a host interface control function ofreceiving a command (i.e., a write command or a read command)transferred from the host system 200 and controlling the data transferbetween the host and the HDC 110. The read/write module 124, which isconnected to the read/write IC 108 and gate array 109, carries out theprocess of reading and writing data via the read/write IC 108. Thebuffer module 125 controls the buffer RAM 111. A part of the storagearea of the buffer RAM 111 is used as a write buffer for temporarilystoring data (or write data) to be written onto the disk 101 via the HDC110 (or the read/write module 124 of the HDC 110). Another part of thestorage area of the buffer RAM 111 is used as a read buffer fortemporarily storing data (or read data) read from the disk 101 via theHDC 110.

Each of the read/write IC 108, gate array 109, and HDC 110 includes acontrol register (not shown). These control registers are allocated to apart of the memory space of the CPU 115. The CPU 115 accesses the partof the memory space, thereby controlling the read/write IC 108, gatearray 109, or HDC 110 via the corresponding control register.

In the HDD 100 of FIG. 1, data is read as follows. First, a signal (oran analog signal) read by the head 102 from the disk 101 is amplified bythe head IC 107. The amplified analog signal is separated by theread/write IC 108 into a servo signal and a data signal. The data signalis decoded by the read/write module 122 of the read/write IC 108 andthen transmitted to the HDC 110. The read/write module 124 of the HDC110 processes the decoded data signal according to the control signalfrom the gate array 109, thereby generating data to be transferred tothe host system 200. This process includes the detection of errors inthe data on the basis of ECC data and the correction of errors. Thegenerated data is temporarily stored in the buffer RAM 111 by the buffermodule 125 of the HDC 110 and then transferred to the host system 200 bythe host module 123 of the HDC 110.

In the HDD 100 of FIG. 1, data is written as follows. Data transferredfrom the host system 200 to the HDC 110 is received by the host module123 of the HDC 110 and then temporarily stored in the buffer RAM 111 bythe buffer module 125 of the HDC 110. The data stored in the buffer RAM111 is read by the buffer module 125 and then transmitted to theread/write IC 108 by the read/write module 124 of the HDC 110 accordingto a control signal from the gate array 109. The data transmitted to theread/write IC 108 is encoded by the read/write module 122 of theread/write IC 108. The encoded data is transmitted to the head 102 viathe head IC 102, which writes the data onto the disk 101. Thereading/writing of the data is performed under the control of the CPU115.

Next, an outline of a data refreshing process carried out at the HDD 100of FIG. 1 will be described with reference to FIG. 3. As describedabove, to save the data on each track to be refreshed into a specifictrack on the disk to take measures against power shutdown during a datarefreshing operation, the head has to be moved over a long distance foreach track. In this case, the data refreshing efficiency decreases. Toovercome this problem, the embodiment uses the following characteristicdata refreshing process, which makes it possible to increase the datarefreshing efficiency by decreasing the number of times the head movesover a long distance, while also taking measures against power shutdownduring the data refreshing process.

Generally, the main purpose of a data refreshing process is to avoid theeffect of write fringing on adjacent tracks on both sides in writingdata onto the individual tracks. Therefore, ideally, it is desirablethat the number of times data is written onto an adjacent track (or thenumber of writes) for each track should be counted and a data refreshingprocess be carried out for each track. However, since a method ofholding the number of writes (or the write count) for all the tracks ona magnetic disk requires a huge memory capacity, the method is notfeasible.

In the embodiment, the tracks 201 arranged on the recording surface ofthe disk 101 are grouped in units of a predetermined number of tracks(e.g., tens to hundreds of tracks). A data refreshing process is carriedout for each group. The groups are called track groups. If the totalnumber of tracks 201 on the disk 101 is 160,000 and the number of tracksper track group is 100, the number of track groups per recording surfaceof the disk 101 is 1/100 of the total number of tracks 201, that is,1600.

In the embodiment, the total number of times data is written into thetrack group (or the number of writes) is counted on a track group basis.If the count (or the write count) has reached a predetermined value, adata refreshing process is performed on the corresponding track group.

In an example in FIG. 3, one track group 301 on the disk 101 is shown.Also in FIG. 3, a system area 302 that can only be used by the system isshown. The system area 302 generally includes one or more tracks. In theembodiment, a part of a specific track in the system area 302 isallocated as a dedicated save area 303 (or a specific save area).Suppose the specific track does not belong to any track group.

When a set of tracks 201 on the disk 101 is sectionalized into aplurality of groups for management, if the following method is used, thetime required to perform a data refreshing process to refresh all thetrack groups can be suppressed. The method involves reading data fromall the tracks in the track group on a track group basis and rewritingthe read data onto all the tracks. This method, however, requires atremendous memory capacity to build a buffer into which data is loaded.

Therefore, in the embodiment, each track group is sectionalized into apredetermined number of segments. Each track group is refreshed insegments sequentially from, for example, the first segment to lastsegment, which enables all the track groups to be refreshed. Here, theprocess in which the first segment is refreshed differs from the processin which the second to last segments are refreshed, as will be describedbelow.

In the example of FIG. 3, track group 301 is sectionalized into an (N+1)number of segments “0” to “N.” Segment “0” represents the first segmentand segment “N” represents the last segment. In FIG. 3, segment element(SE) 2 a located at the trailing end of the first track 201 in trackgroup 301 and segment element (SE) 2 b located at the leading end of thetrack 201 following the first track 201 constitute segment “2.”

Segment “0” of track group 301 is so set that its segment length islonger than that of the other segments “1” to “N” of track group 301 bytwo sectors. That is, if each of segments “1” to “N” is composed of Lsectors, segment “0” is composed of (L+2) sectors. On the other hand,the dedicated save area 303 is so set that its size is longer than thatof segment “0” by two sectors. That is, if segment “0” is composed of(L+2) sectors, the dedicated save area 303 is composed of (L+4) sectors.

The CPU 115 performs a data refreshing process on track group 301 in thefollowing procedure.

(1) A save operation 321 is carried out to save the data stored in thefirst segment “0” of track group 301 (i.e., the data in (L+2) sectors)into the dedicated save area 303. One-sector header and one-sectorfooter are added to the front and rear of the data in the (L+2) sectors,respectively.

That is, the save operation 321 includes

1a) the operation of reading (L+2) sectors of data stored in segment “0”and writing the read (L+2) sectors of data into the buffer RAM 111

1b) the operation of adding a header and a footer to the read (L+2)sectors of data

1c) the operation of writing the header-and-footer-added (L+4) sectorsof data into the dedicated save area 303.

The save operation 321 is a part of a data refreshing operation 320 forrefreshing segment “0” (the first segment). The remaining part of thedata refreshing operation 320 is carried out after all of the datarefreshing operations 322 ₋₁ to 322 _(-N) for refreshing segments “1” to“N” (the second segment) respectively have been completed.

(2) A data refreshing operation 322 ₋₁ is carried out to refresh thedata (i.e., the L sectors of data) stored in the second segment “1” oftrack group 301.

The data refreshing operation 322 ₋₁ includes

2a) the operation of reading the L sectors of data stored in segment “1”and of writing the read L sectors of data into the buffer RAM 111

2b) the operation of adding one-sector header and one-sector footer tothe front and rear of the read L sectors of data, respectively

2c) the operation of writing (or saving) the header-and-footer-added(L+2) sectors of data into segment “0” and

2d) the operation of refreshing the data stored in segment “1” byrewriting the read L sectors of data into segment “1”

2e) the operation of invalidating the data saved in segment “0.”

As described above, segment “0” is used as a temporary save area inrefreshing the data stored in the segment “1.” In the embodiment, thedata saved in segment “0” is invalidated by invalidating, for example,the header of the header and footer added to the data. A header andfooter are called a valid header and footer only when both the headerand footer are valid. Therefore, if the header of the header and footeris invalidated, the header and footer are not a valid header and footer.

(3) The same data refreshing operations 332 ₋₂ to 332 _(-N) N as thoseperformed on segment “1” are performed on subsequent segments “2” to N,”respectively. Accordingly, segment “0” is also used as a temporary savearea in refreshing the data stored in segments “2” to “N.”

(4) After the data refreshing operation 322 _(-N) has been performed onthe last segment “N” of track group 301, an unfinished data refreshingoperation 320 is performed on segment “0.” That is, a rewrite operation323 is performed. The rewrite operation 323 is the data refreshingoperation 320 excluding the already-performed save operation 321.

The rewrite operation 323 includes

4a) the operation of reading the data saved from segment “0” to thededicated save area 303 in the save operation 321 and of writing theread data into the buffer RAM 111

4b) the operation of refreshing the data stored in segment “0” byrewriting the read data into segment “0”

4c) the operation of invalidating the header added to the data stored inthe dedicated save area 303.

As a result of the rewrite operation 323 being performed, the datastored in segment “0” of track group 301 is refreshed. This completesthe data refreshing process on track group 301.

In such a data refreshing process, when all the segments “0” to “N” intrack group 301 are refreshed, a long-distance seek operation isperformed only four times. A long-distance seek operation is carried outto move the head 102 between track group 301 and the dedicated save area303 away from track group 301. In contrast, when the data in segments“0” to “N” is saved, if the dedicated save area 303 is always used as inthe conventional art, a long-distance seek operation is performed asmany as 4×(N+1) times. Accordingly, with the embodiment, the number oflong-distance seek operations per track group can be reduced remarkablyas compared with in the conventional art and therefore the datarefreshing efficiency can be improved.

Here, suppose the number of tracks per track group is 100 and the numberof tracks per recording surface of the disk 101 is 160,000. In thiscase, the average head moving distance in a seek operation performedbetween the first segment and each of the second to last segments of thetrack group is 1/1600 of the average head moving distance in along-distance seek operation.

When the power supply of the HDD 100 is shut down during a datarefreshing process, the CPU 115 performs a restoration process in thefollowing procedure, thereby realizing the detection of the powershutdown and the restoration of the data.

(Procedure A) The data saved in the dedicated save area 303 is read intothe buffer RAM 111.

(Procedure B1) If a valid header and footer have not been added to thedata read from the dedicated save area 303, it is determined that thereis no data to be restored by using the read data. In this case, therestoration process is terminated.

(Procedure B2) On the other hand, if a valid header and footer have beenadded to the data read from the dedicated save area 303, it isdetermined that there is data to be restored. In this case, the data inthe first segment “0” is read into the buffer RAM 111.

(Procedure B2-1) If a valid header and footer have not been added to thedata read from segment “0,” it is determined that there is no data to berestored by using the data read from segment “0.” In this case, it isdetermined that there is data to be restored by using the data read fromthe dedicated save area 303, and control is passed to procedure C.

(Procedure B2-2) On the other hand, if a valid header and footer areadded to the data read from segment “0,” it is determined that there isdata to be restored by using the data read from segment “0.” In thiscase, the data read from segment “0” is written into the correspondingsegment and then the header added to the data saved in segment “0” isinvalidated.

(Procedure C) The data read from the dedicated save area 303 is writteninto segment “0” and then the header added to the data saved in thededicated save area 303 is invalidated.

FIG. 4 shows a data structure of the write count table 400 which holdsthe number of writes (or the write count) for each track group. Thewrite count table 400 is stored in, for example, a predetermined area ofthe RAM 113 of FIG. 1. That is, the predetermined area of the RAM 113 isused as a write count storage module which stores the write count table400.

In the example of the write count table 400 shown in FIG. 4, togeneralize the explanation, it is assumed that the HDD 100 includes an mnumber of heads 102 and that the HDD 100 is composed of an n number ofcylinder groups. In this case, the write count table 400 holds the writecount (or the number of writes) W(h, c) (0≦h≦m−1, 0≦c≦n−1) for each ofall of the track groups represented by a head (or head number) h and acylinder group (or cylinder group number) c. The write count for a trackgroup is the number of times the operation of writing data into thetrack group was performed. W(h, c) is used as a write counter whichcounts the number of writes for a track group specified by the headnumber h and cylinder group number c. In the case of the configurationof the HDD 100 shown in FIG. 1, m is 1.

A cylinder group is a set of a predetermined number of cylinders. Thenumber of cylinders per cylinder group is the same as the number oftracks per track group. Accordingly, in the HDD 100, the number of trackgroups with the same cylinder number is the same as the number of heads102 (that is, m). The track group is specified by the cylinder groupnumber c and head number h. When data is written (or write access isperformed) onto a track in the track group specified by the cylindergroup c and head number h, the write counter (or the write count) W(h,c) held in the count table 400 is incremented by the number of timeswriting was done.

In the embodiment, the write count table 400 is stored in the RAM 113 asdescribed above. The contents of the RAM 113 are lost as a result of thepower shutdown of the HDD 100. Accordingly, the contents of the writecount table 400 are also lost at the time of the power shutdown.Therefore, in the embodiment, the contents of the predetermined area ofthe RAM 113 including the write count table 400 are saved into apredetermined area of the disk 101 as needed (e.g., when the HDD 100goes into a power saving state). The contents including the count table400 saved in the predetermined area of the disk 101 are read at the timeof the start-up of the HDD 100 (or when the power supply is turned on)and restored in the RAM 113.

Next, an overall operation of refreshing data in track groups at the HDD100 of FIG. 1 will be explained with reference to a flowchart in FIG. 5.First, suppose the power supply of the HDD 100 is turned on and theoperation of the CPU 115 is started (block 501). Then, the CPU 115performs the following initialization and restoration processes (block502). First, the CPU 115 performs a known initialization process on theentire HDD 100. Then, the CPU 115 performs a restoration process relatedto a data refreshing process. In the restoration process, the CPU 115checks whether the power supply was shut down in a state a datarefreshing process was interrupted during the preceding operation. Ifthe power supply was shut down, the CPU 115 performs control to completethe data refreshing process. In the restoration process, the write counttable 400 saved in the predetermined area of the disk 101 is read andstored into the RAM 113.

After the initialization and restoration processes have been completed,the CPU 115 goes into a state where it can receive a command from thehost system 200 via the HDC 110. That is, the CPU 115 goes into acommand state loop (blocks 503 to 507). In block 503, if havingacknowledged the reception of a command from the host system 200 inblock 503, the CPU 115 branches to block 511, thereby escaping from thecommand state loop and performing a process corresponding to the commandfrom the host system 200 (a command process).

On the other hand, suppose it has been determined that the CPU 115 hasreceived no command in block 503 in the command state loop. In thiscase, an idle time processing is performed. After the command executionprocess has been completed in block 511, an idle time processing is alsoperformed. The idle time processing includes a data refreshing process.In the embodiment, before going to the data refreshing process, the CPU115 determines whether to perform the data refreshing process (blocks504, 505).

In block 504, for example, the CPU 115 determines in a comprehensivemanner whether to execute the command from the host system 200immediately without performing a data refreshing process or to avoid adata refreshing process. It is when the CPU 115 receives the commandfrom the host system 200 immediately after, for example, block 511 isexecuted that the CPU 115 needs to execute the command immediately. Itis when a data refreshing process should be avoided that the HDD 100 isused under bad conditions. Such a state includes, for example, a casewhere a vibration that exceeds a predetermined level is externallysupplied to the HDD 100 and a case where the environmental temperatureof the HDD 100 has exceeded a guaranteed operational temperature rangeof the HDD 100.

In block 505, the CPU 115 determines from the results of a comprehensivedetermination in block 504 whether the data track refreshing process isfeasible. Only when having determined that the data refreshing processis feasible does the CPU 115 perform the data refreshing process (block506). The data refreshing process will be described in detail later.

If having determined that the data refreshing process is terminated inblock 506 or should not be performed in block 505, the CPU 115 proceedsto block 507. In block 507, the CPU 115 determines whether to perform apower saving process to cause the HDD 110 to transit to a power-savingstate. If it is determined that the power saving process needs to beperformed, the CPU 115 performs the power-saving process. Thepower-saving process includes an unload process of unloading the head102 from the disk 101 and/or the process of stopping the rotation of theSPM 103.

If the power-saving process has been performed in block 507, the CPU 115returns to block 503. In contrast, if the command from the host 200needs to be executed immediately, the CPU 115 determines that thepower-saving process should not be performed in block 507. In this case,the CPU 115 returns to block 503 without performing the power-savingprocess. From this point on, the CPU 115 repeats the above processesincluding block 503.

Next, the details of the initialization and restoration processesperformed in block 502 will be explained with reference to a flowchartin FIG. 6. In the flowchart of FIG. 6, the processes unrelated to datarefreshing are omitted. Suppose the initialization and restorationprocesses are started (block 601). Then, the CPU 115 reads the writecount table 400 saved on the disk 101 and stores the table 400 into thepredetermined area of the RAM 113. Thereafter, the CPU 115 reads thedata saved in the dedicated save area 303 into the buffer RAM 111 (block602).

As described above, in the data refreshing operation, when the data in acertain segment of a track group (e.g., track group 301) is read, aheader and a footer are added to the read data. Theheader-and-footer-added data is saved into a save location (or thededicated save area 303 or the first segment “0” of track group 301).Thereafter, the read data is rewritten into the certain segment. Lastly,to invalidate the data saved in the save location, the header added tothe data is invalidated (i.e., cleared). This completes the datarefreshing operation.

Accordingly, if the data refreshing operation has been completed, thevalid data (that is, the valid-header-footer-added data) will never beleft in the save location. Conversely, if the valid-header-footer-addeddata is left in the save location, this means that an unexpected powershutdown has occurred in the middle of a data refreshing operation. Inthis case, there is a high possibility that power shutdown took place inthe middle of writing data into a segment (or a original location) inwhich the data saved in the save location ought to be stored and thedata in the segment was destroyed. Therefore, the data saved in the savelocation has to be written into the original location reliably.

The CPU 115 makes a determination for that in block 603. The targets tobe determined in block 603 are the header and footer added to the dataread from the dedicated save area 303 into the buffer RAM 111. That is,in block 603, the CPU 115 determines whether a valid header and footerhave been added to the data read from the dedicated save area 303.

In the embodiment, the header and footer include the same information.Accordingly, in the embodiment, the invalidation of the data saved inthe save location is realized by clearing the header of the header andfooter added to the data. In this case, checking whether the contents ofthe header are the same as those of the footer make it possible todetermine (detect) whether the header and footer are valid.

Here, suppose the CPU 115 has determined that a valid header and footerhave not been added to the data read from the dedicated save area 303(NO in block 603). The result of the determination means that the datarefreshing operation 320 using the dedicated save area 303 as a savelocation (see FIG. 3) has been completed and therefore the lastperformed refreshing process for the track group (e.g., track group 301)has been completed. In this case, it is not necessary to check the firstsegment “0” serving as another save location. Then, the CPU 115 branchesto block 610 to terminate the initialization and restoration processesand then proceeds from block 502 to block 503 as shown in the flowchartof FIG. 5.

In contrast, suppose the CPU 115 has determined that a valid header andfooter have been added to the data read from the dedicated save area 303(YES in block 603). That is, it is assumed that a valid header andfooter have been detected from the dedicated save area 303. The resultof the determination means that the last performed data refreshingprocess for the track group has not been completed. The track groupperformed in the last performed data refreshing process can bepinpointed by the valid header and footer as described later. Here,suppose the track group is track group 301.

In the data refreshing operation 320 using the dedicated save area 303as a save location, a saving operation 321 is performed to save the datain the first segment “0” at the very beginning of the data refreshingprocess for track group 301. Then, a rewrite operation 323 is performedat the very end of the data refreshing process for track group 301. Inthe rewrite operation 323, the data saved in the dedicated save area 303is rewritten into the first segment “0” and then the header added to thedata saved in the dedicated save area 303 is invalidated.

Accordingly, since the result of the determination in block 603 is YES,the CPU 115 only detects that the data refreshing process for trackgroup 301 has not been completed. Thus, the CPU 115 reads the data savedin the first segment “0” of track group 301 which is used as a savelocation (block 604). Then, the CPU 115 determines whether a validheader and footer have been added to the data read from segment “0”(block 605).

If a valid header and footer have been added to the data read fromsegment “0” (YES in block 605), the CPU 115 branches to block 606. Inblock 606, the CPU 115 writes the data read from segment “0” from whichthe header and footer have been removed into the corresponding segment,the original location. Next, the CPU 115 invalidates (or clears) theheader added to the data saved in segment “0” (block 607). As a result,the CPU 115 ends the restoration process using segment “0.” Then, toperform the restoration process using the dedicated save area 303, theCPU 115 branches from block 607 to block 608.

In the embodiment, each of the valid header and footer added to the datasaved in the dedicated save area 303 holds a predetermined characterstring indicating that the header and footer are valid and attributeinformation indicating the address (e.g., logical block address LBA) ofthe first sector of segment “0” and the length (or the size) of segment“0” and the like. Accordingly, segment “0” from which data is to be readin block 604 and track group 301 to which segment “0” belongs can bespecified from the attribute information (logical block address LBA andlength) in the header and footer.

Similarly, each of the valid header and footer added to the data savedin segment “0” used as a temporary save area holds the predeterminedcharacter string and attribute information indicating the logical blockaddress LBA of the first sector of the corresponding segment, theoriginal location, and the length of the corresponding segment and thelike. Accordingly, the corresponding segment can be specified from theattribute information (logical block address LBA and length) in theheader and footer.

On the other hand, if the valid header and footer have not been added tothe data read from segment “0” (NO in block 605), the CPU 115 skipsblocks 606 and 607 and branches to block 608. It is when the powersupply is shut down immediately after the data refreshing operation 322_(-N) for the last segment “N” of track group 301 has been completedthat the result of the determination in block 605 is NO. In addition tothis, in the data refreshing operation 322-i for segment “i” (i=1, 2, N)excluding the first segment “0,” if the power supply is shut down beforethe data in segment “i” is saved into the save location (i.e., segment“0”) (e.g., in the middle of reading data from segment “i”), the resultof the determination in block 605 is NO.

In block 608, the CPU 115 writes into the first segment “0” the dataread from the dedicated save area 303 into the buffer RAM 111 in block602 excluding the header and footer. Next, the CPU 115 clears the headeradded to the data stored in the dedicated save area 303, therebyinvalidating the header (block 609). Then, the CPU 115 branches to block610 to terminate the initialization and restoration processes andproceeds from block 502 to block 503 as shown in the flowchart of FIG.5.

In a state where the initialization and restoration processes shown inthe flowchart of FIG. 6 have been completed, the data in another segmenthas not been saved into segment “0” used as a save location (or atemporary save area) in the last data refreshing process. That is, thedata in all the segments of a track group to be subjected to the datarefreshing process (hereinafter, referred to as the corresponding trackgroup) including the data in segment “0” can be accessed properly.

Here, the purpose of the initialization and restoration processes is torestore the data from unexpected power shutdown that occurred in themiddle of the data refreshing process. The completion of theinitialization and restoration processes does not mean the completion ofthe corresponding track group. This is because what are restored in theinitialization and restoration processes are only the data in thesegment subjected to a data refreshing process at the time of powershutdown and the data in the first segment “0” used as a save locationfor the data refreshing process. That is, this is because, in theinitialization and restoration processes, the remaining part of the datarefreshing process interrupted due to power shutdown is not performed.

In the embodiment, to overcome this problem, after the correspondingtrack group has been subjected to the initialization and restorationprocesses (block 502) of FIG. 5, the data refreshing process isperformed again, starting from the first segment “0” of thecorresponding track group. The reason this is done is that, in the datarefreshing process, the process of clearing the corresponding count inthe write count table 400 is not performed until all of the segments inthe track group have been subjected to the data refreshing process. Thetrack group is detected again as a track group to be refreshed bysearching the write count table 400 after the completion of theinitialization and restoration processes.

Next, a detailed procedure for a command execution process performed inblock 511 will be explained with reference to a flowchart in FIG. 7. Asdescribed above, the command execution process is performed when acommand from the host system 200 is received. As a result, a processcorresponding to the command is performed. If a data refreshing processis being performed on a certain track group, such as track group 301,when a command is received, the first segment “0” in track group 301 isused as a save location (or a temporary save area) for a data refreshingprocess for another segment in track group 301. That is, data in anothersegment “0” of track group 301 has been saved in segment “0.” The datain segment “0” has been saved in the dedicated save area 303. Therefore,if the received command requests access to an area overlapping with atleast a part of the first segment “0,” it is necessary to access thededicated save area 303 in place of segment “0.” That is, it isnecessary to correct the access range specified by the received command.The access range is corrected in a command execution process.

If the command execution process is started (block 701), the CPU 115determines whether the HDD 110 is in the refreshing process mode (block702). In the refreshing process mode, a data refreshing operation isperformed on each segment in the selected track group.

If the HDD 100 is not in the refreshing process mode (NO in block 702),the CPU 115 branches to block 705 and performs a command process. Incontrast, if the HDD 100 is in the refreshing process mode (YES in block702), the CPU 115 branches to block 703. In block 703, the CPU 115determines whether at least a part of the access range on the disk 101specified by the received command overlaps with the first segment “0” ofthe track group subjected to the data refreshing process now beingperformed. The access range is specified by the address (e.g., thelogical block address LBA) and size specified by the received command.The CPU 115 determines on the basis of the result of the determinationin block 703 whether the correction of the access range is needed.

If it has been determined that at least a part of the access range doesnot overlap with the segment “0” (NO in block 703), the CPU 115determines that the correction of the access range is unnecessary andbranches to block 705. In contrast, if it has been determined that atleast a part of the access range overlaps with the segment “0” (YES inblock 703), the CPU 115 corrects the access range (block 704).

In block 704, the overlapped part of the access range specified by thereceived command is changed so as to indicate the dedicated save area303. This causes the dedicated save area 303, not the overlapped part,to be accessed in the access range. On the other hand, the remainingpart is accessed in a normal manner. Accordingly, for example, if such awrite command as specifies an access range a part of which overlaps withthe first segment “0” has been received, the writing of data into thededicated save area 303 and the writing of data into the remaining partof the specified access range are performed consecutively.

Next, a detailed procedure for the data refreshing process performed inblock 506 will be explained with reference to flowcharts in FIGS. 8 and9. Suppose a data refreshing process is started (block 801). Then, theCPU 115 determines whether the HDD 100 is in the refreshing process mode(block 802). The determination in block 802 is made for the followingreason. First, it takes a long time to refresh all of the segments in atrack group. To prevent a decrease in the response to the commandreceived from the host system 200 during the period of the refreshingprocess mode, it is desirable for the data refreshing process to beinterrupted each time the data refreshing process is performed segmentby segment. The determination in block 802 is related to this.

It is after the search of the write count table 400 (blocks 804 and 805)is completed that the HDD 100 is set in the refreshing process mode. Therefreshing process mode is not cancelled until all the segments in thecorresponding track group have been refreshed. Therefore, if the HDD 100is in the refreshing process mode after the start of the data refreshingprocess (YES in block 802), a segment to be refreshed has always beenspecified. Therefore, if the result of the determination in block 802 isYES, the CPU 115 branches to block 806 and performs a refreshingoperation.

On the other hand, if the HDD 100 is not in the refreshing process mode(NO in block 802), the CPU 115 refers to the write count table 400,thereby detecting the write count W(h, c) indicating the maximum numberof writes (block 803). Then, the CPU 115 determines whether a trackgroup specified by the head number h and cylinder group number c needsrefreshing, depending on whether the number of writes represented by thedetected write count W(h, c) has exceeded a threshold value (block 804).That is, the CPU 115 determines whether there is a track group whichneeds refreshing.

If there is a track group which needs refreshing (YES in block 804), theCPU 115 sets the HDD 100 in the refreshing process mode to perform datarefreshing on the corresponding track group (block 805). In block 805,the CPU 115 sets a segment pointer for specifying a segment to berefreshed next in the track group so that the pointer may indicate thefirst segment “0” of the track group. Here, the segment pointer is setto “0” indicating the first segment “0.” This segment pointer is storedin a predetermined area of the RAM 113. Next, the CPU 115 performs theprocesses in block 806 and forward.

In contrast, if there is no track group which needs refreshing (NO inblock 804), the CPU 115 need not perform the data refreshing process andtherefore branches to block 814 to terminate the data refreshing processand then proceeds from block 506 to block 507 as shown in the flowchartof FIG. 5.

As described above, in blocks 504 and 505, too, the CPU 115 determineswhether to perform a data refreshing process. Blocks 504 and 505,however, differ from blocks 803 and 804 in that the determination is notmade on the basis of the write count table 400, that is, it is notdetermined whether there is a track group which needs a data refreshingprocess.

Here, when blocks 504 and 505 are executed, if the write count table 400needs referring to, determinations corresponding to blocks 803 and 804may be made in blocks 504 and 505. For example, this corresponds to acase where whether the aforementioned data refreshing process should beavoided is determined on the basis of both of the level of the operatingenvironment of the HDD 100 and the number of writes indicated by eachwrite count in the write count table 400. For example, during the timewhen the number of times data is written into the track group (or thenumber of writes) is small even if the level of the operatingenvironment is the same, the deterioration of the data in each segmentof the track group is little. In such a state, the risk in passing upthe data refreshing process is lower than the risk in performing thedata refreshing process under bad conditions. In contrast, as the numberof writes increases, the deterioration of the data in each segment inthe track group gets worse. In such a state, the risk in performing thedata refreshing process even under slightly bad conditions is lower thanin passing up the data refreshing process. If such determinations aremade in blocks 504 and 505, a track group whose number of writes is thelargest is specified and the number of writes is obtained in blocks 504and 505. In this case, such determinations are not necessarily made inblocks 803 and 804.

Then, in block 806, the CPU 115 determines (or detects) whether the lastsegment of the track group subjected to the data refreshing process hasbeen refreshed. The determination is made on the basis of theaforementioned segment pointer. Specifically, the CPU 115 determineswhether the last segment “N” has been refreshed, depending on whetherthe segment pointer has been set to “N+1.” In the explanation below,suppose track group 301 is to be subjected to the data refreshingprocess.

If the last segment “N” has not been refreshed (NO in block 806), theCPU 115 branches to block 807. In block 807, the CPU 115 determines (ordetects) whether a segment to be refreshed next is the first segment “0”in track group 301 or one of the other segments “1” to “N” (second trackgroup).

First, if a segment to be refreshed next is the first segment “0” intrack group 301 (YES in block 807), the CPU 115 branches to block 821.That is, if the first data refreshing operation 320 is carried out inthe data refreshing process for track group 301, the CPU 115 branches toblock 821.

As described above, the first segment “0” in track group 301 is used asan area (a temporary save area) into which the data in each of thesecond segment “1” to last segment “N” in track group 301 is saved.Then, in block 821, the CPU 115 reads the data in the first segment “0”into the buffer RAM 111 before the first segment “0” is used as atemporary save area. Then, the CPU 115 adds a header and a footer to thefront and rear of the data in the read first segment “0” respectivelyand writes the header-and-footer-added data into the dedicated save area303 (block 822). This causes the data in the first segment “0” to besaved into the dedicated save area 303. Blocks 821 and 822 correspond tothe aforementioned save operation 321 (see FIG. 3).

In a state where block 822 has been executed, the data refreshingprocess 320 for the first segment “0” has not been completed. In theembodiment, however, the CPU 115 increments the segment pointer so thatthe segment pointer may point at segment “1” to be refreshed next toperform data refreshing operation 322 ₋₁ on the next segment “1” (block812).

On the other hand, if a segment to be refreshed next is one of thesecond segment “1” to last segment “N” in track group 301 (hereinafter,referred to as segment “i”) (NO in block 807), the CPU 115 branches toblock 808. In block 808, the CPU 115 reads the data in segment “i” (i=1,2, N) into the buffer RAM 111.

Next, the CPU 115 adds a header and a footer to the front and rear ofthe data in the read segment “i” respectively and writes theheader-and-footer-added data into the first segment “0” of track group301 (block 809). That is, the CPU 115 uses segment “0” as a temporarysave area for the data in segment “1” and saves the data read fromsegment “i” and added with the header and footer into the segment “0.”

Next, the CPU 115 writes (or rewrites) the data read from segment “i”into the buffer RAM 111 into the segment “1,” thereby refreshing thesegment “i” (block 810). Next, the CPU 115 clears (or invalidates) theheader added to the data saved in the first segment “0” (block 811).This completes the data refreshing operation 320 _(-i) for refreshingsegment “i.” Then, the CPU 115 increments the segment pointer from “i”to “I+1” (block 812) to cause the segment pointer to point at segment“i+1” to be refreshed next.

If the last segment “N” has been refreshed (YES in block 806), the CPU115 branches to block 831. In a state where the last segment “N” hasbeen refreshed, the data in the first segment “0” has been saved intothe dedicated save area 303 in blocks 821 and 822 (in the save operation322 in the data refreshing operation 320). Here, the data refreshingoperation 320 has not been completed and the first segment “0” has notbeen refreshed.

Accordingly, in block 831, the CPU 115 reads the data in the firstsegment “0” saved in the dedicated save area 303 into the buffer RAM 111in order to refresh the first segment “0” (block 831). Next, the CPU 115writes (or rewrites) the data read from the dedicated save area 303 intothe buffer RAM 111 into the first segment “0,” thereby refreshing thefirst segment “0” (block 832). Next, the CPU 115 clears (or invalidates)the header added to the data saved in the dedicated save area 303 (block833).

This completes the data refreshing operation 320 for refreshing thefirst segment “0.” That is, all of segments “0” to “N” in track group301 have been refreshed. To indicate that there is no track group beingsubjected to a refreshing process, the CPU 115 cancels the refreshingprocess mode (block 834). Block 834 is needed to make a correctdetermination in blocks 702 and 802.

Next, the CPU 115 clears the write count corresponding to track group301 in the write count table 400 (i.e., the track group subjected to therefreshing process) (block 835). As a result, the value of the writecount corresponding to track group 301 is 0. The meaning of block 835will be explained below.

Each write count in the write count table 400 indicates the number oftimes data was written into the corresponding track group (or the numberof writes) as described above. The number of writes correlates with thedegree of deterioration of the data in the corresponding track group.Accordingly, the number of writes is treated as the degree ofdeterioration of data for the purpose of convenience. Immediately afterthe refreshing process for a track group, there is no deterioration ofdata in the track group. To reflect this on the corresponding writecount in the write count table 400, block 835 is executed.

The CPU 115 then executes block 812 and branches to block 813. Whenhaving executed block 835, the CPU 115 also branches to block 813. Thatis, when having refreshed any one segment in the track group subjectedto the refreshing process, the CPU 115 branches to block 813.

In block 813, the CPU 115 determines whether there is a request for theinterruption of the refreshing process. The reception of a command fromthe host system 200 is one of the conditions for making a request forthe interruption of the refreshing process. If the host module 123 ofthe HDC 110 receives a command from the host system 200, the HDD 100immediately goes into a busy state and, at the same time, sets a busyflag indicating the busy state. The CPU 115 then monitors the state ofthe flag. The busy flag is set, regardless of whether the datarefreshing process is being performed. Accordingly, the response time ofthe command recognized by the host system 200 is the sum of the timerequired to complete the data refreshing process now being performed andthe original command execution time. When the command from the hostsystem 200 is received, if the execution of the command is made to waituntil the data refreshing process has been completed, the responsivenessto the command will be degraded. To avoid this, block 813 is executed.

If there is a request for interruption of the refreshing process (YES inblock 813), the CPU 115 branches to block 814 to immediately interruptthe data refreshing process and proceeds from block 506 to block 507 asshown in the flowchart of FIG. 5. In this case, the CPU 115 executes thesame process in block 507 as in block 813 in order to immediately branchto block 503 and start a process (or command execution process) for thereceived command.

In contrast, if there is no request for interruption of the refreshingprocess (NO in block 813), the CPU 115 branches again to block 802 todetermine whether the HDD 100 is in the refreshing process mode. Here,in a state where all of the segments in the track group have beenrefreshed, the refreshing process mode has been cancelled in block 834.That is, the HDD 100 is not in the refreshing process mode (NO in block802). In this case, as described above, the CPU 115 searches for a trackgroup which needs refreshing on the basis of the write count table 400(blocks 803 and 804). If there is no track group which needs refreshing(NO in block 804), the CPU 115 branches to block 814 to terminate thedata refreshing process. As described above, if there is no request forthe interruption of the refreshing process (NO in block 813), it is onlywhen no track group needing the refreshing process left is present thatthe data refreshing process is terminated (NO in block 804).

On the other hand, in a state where one of the segments excluding thefirst segment “0” (i.e., one of segments “1” to “N”) in the track grouphas been refreshed, the refreshing process mode has not been cancelled.That is, the HDD 100 is in the refreshing process mode (YES in block802). In this case, the CPU 115 branches to block 806.

The various modules of the magnetic disk drive described herein can beimplemented as software applications, hardware and/or software modules.While the various modules are illustrated separately, they may sharesome or all of the same underlying logical or code.

While certain embodiments of the inventions have been described, theseembodiments have been presented by way of example only, and are notintended to limit the scope of the inventions. Indeed, the novelapparatuses and methods described herein may be embodied in a variety ofother forms; furthermore, various omissions, substitutions and changesin the form of the apparatuses and methods described herein may be madewithout departing from spirit of the inventions. The accompanying claimsand their equivalents are intended to cover such forms or modificationsas would fall within the scope and spirit of the inventions.

What is claimed is:
 1. A method of refreshing data on a disk in amagnetic disk drive, the disk comprising a plurality of track groups,each of the plurality of track groups comprising one or more datatracks, the one or more data tracks comprising a first segment and asecond segment, the method comprising: saving first data in the firstsegment into a predetermined area on the disk before refreshing thefirst segment and the second segment in one of the plurality of trackgroups; saving second data in the second segment into the first segmentafter saving the first data; rewriting the second data into the secondsegment in order to refresh the second data in the second segment aftersaving the second data; and rewriting the first data in thepredetermined area into the first segment after refreshing the secondsegment.
 2. The method of claim 1, wherein the predetermined area isoutside of the first segment and the second segment.
 3. The method ofclaim 2, wherein: the saving second data comprises: reading the seconddata from the second segment; and adding a header and a footerindicating validity of the read second data to the head and tail end ofthe read second data, respectively; and the size of the first segment islarger than the second segment by a size corresponding to the header andfooter.
 4. The method of claim 3, wherein: the read second data isrewritten into the second segment after the header-and-footer-addedsecond data is saved into the first segment; and the method furthercomprises invalidating the header added to the second data in the firstsegment after rewriting the read second data into the second segment. 5.The method of claim 4, wherein: the saving first data comprises: readingthe first data from the first segment; and adding a header and a footerindicating validity of the read first data to the head and tail end ofthe read first data, respectively; and the size of the predeterminedarea is larger than the first segment by a size corresponding to theheader and footer.
 6. The method of claim 5, further comprisinginvalidating the header added to the first data in the predeterminedarea after rewriting the first data in the predetermined area into thefirst segment.
 7. The method of claim 6, further comprising detectingwhether the power supply of the magnetic disk drive is shut down duringrefreshing, on the basis of the header and footer added to the firstdata in the predetermined area and the header and footer added to thesecond data in the first segment.
 8. The method of claim 7, furthercomprising: rewriting the second data in the first segment into thesecond segment when a valid header and footer are added to both of thefirst data in the predetermined area and the second data in the firstsegment; and invalidating the header added to the second data in thefirst segment after rewriting the second data in the first segment intothe second segment.
 9. The method of claim 8, wherein: the valid headerand footer added to the second data in the first segment comprise acharacter string indicating that the header and footer are valid andattribute information addressing the second segment storing the seconddata; and the second segment is identified based on the attributeinformation in the valid header and footer added to the second datasaved in the first segment.
 10. The method of claim 9, furthercomprising: rewriting the first data in the predetermined area into thefirst segment when at least a valid header and footer are added to thefirst data in the predetermined area; and invalidating the header addedto the first data in the predetermined area after rewriting the firstdata in the predetermined area into the first segment.
 11. A magneticdisk drive comprising: a disk comprising a plurality of track groups,each of the plurality of track groups comprising one or more datatracks, and the one or more data tracks comprising a first segment and asecond segment; and a controller configured to control refreshing dataon the disk, wherein the controller is configured to save first data inthe first segment into a predetermined area on the disk beforerefreshing the first segment and the second segment in one of theplurality of track groups, to save second data in the second segmentinto the first segment after saving the first data, to rewrite thesecond data into the second segment in order to refresh the second datain the second segment after saving the second data, and to rewrite thefirst data in the predetermined area into the first segment afterrefreshing the second segment.
 12. The magnetic disk drive of claim 11,wherein the predetermined area is outside of the first segment and thesecond segment.
 13. An electronic apparatus comprising: the magneticdisk drive of claim 11; and a host configured to use the magnetic diskdrive as a storage module.